#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int findNumberOfLIS(vector<int>& nums) {
        int n = nums.size();
        if (n == 1) return 1;
        vector<int> dp(n, 1);
        vector<int> f(n, 1);
        int MAX = 0;
        int m = 0;
        for (int i = 1;i < n;i++)
        {
            for (int j = i;j >= 0;j--)
            {
                if (nums[i] > nums[j])
                {
                    if (j == 5)
                    {
                        cout << dp[i] << " " << dp[j] << endl;
                    }
                    if (dp[j] + 1 > dp[i])
                    {
                        dp[i] = dp[j] + 1;
                        f[i] = f[j];
                    }
                    else if (dp[j] + 1 == dp[i])
                    {
                        f[i] += f[j];
                    }
                }
            }
            if (dp[i] > MAX)
            {
                MAX = dp[i];
                m = i;
            }
        }
        cout << endl;
        for (int i = 0;i < n;i++)
        {
            cout << dp[i] << " ";
        }
        cout << endl;
        for (int i = 0;i < n;i++)
        {
            cout << f[i] << " ";
        }
        int ret = 0;
        for (int i = 0;i < n;i++)
        {
            if (dp[i] == MAX)
            {
                ret += f[i];
            }
        }
        return ret;
    }
};
int main()
{
    Solution s1;
    vector<int> v = { 1, 1, 1, 2, 2, 2, 3, 3, 3 };
    s1.findNumberOfLIS(v);
    return 0;
}